package ncu.me.musicplayer.http;

import android.util.Log;

import java.io.InputStream;
import java.util.List;

import ncu.me.musicplayer.entity.MusicInfo;

/**
 * @Author ye
 * @Date 2020/6/1 21:49
 * @Version 1.0
 */
public interface IMusicHttp {
    void search(String key,SearchResult result);
    void get(String mid,GetResult result);
    void download(String url,DownloadResult result);
    void load(String url,StreamResult result);
    interface Result{
        void onSuccess(String string);
        void onFailure(String msg);
        void onError(Exception e);
    }
    interface SearchResult{
        void onSuccess(List<MusicInfo> list);
        default void onFailure(String msg){
            Log.e("SearchResult",msg);
        }
        default void onError(Exception e){
            onFailure(e.getMessage());
            e.printStackTrace();
        }
    }
    interface GetResult{
        void onSuccess(MusicInfo musicInfo);
        default void onFailure(String msg){
            Log.e("SearchResult",msg);
        }
        default void onError(Exception e){
            onFailure(e.getMessage());
            e.printStackTrace();
        }
    }
    interface DownloadResult{
        void onSuccess(String filePath);
        default void onFailure(String msg){
            Log.e("SearchResult",msg);
        }
        default void onError(Exception e){
            onFailure(e.getMessage());
            e.printStackTrace();
        }
    }
    interface StreamResult{
        void onSuccess(InputStream bytes);
        default void onFailure(String msg){
            Log.e("SearchResult",""+msg);
        }
        default void onError(Exception e){
            onFailure(e.getMessage());
            e.printStackTrace();
        }
    }
}
